sap.ui.define([
	"sap/ui/core/format/FileSizeFormat"
], function(FileSizeFormat) {
	"use strict";
	return {
		/**
		 * Rounds the currency value to 2 digits
		 *
		 * @public
		 * @param {string} sValue value to be formatted
		 * @returns {string} formatted currency value with 2 digits
		 */
		currencyValue: function(sValue) {
			if (!sValue) {
				return "";
			}

			return parseFloat(sValue).toFixed(2);
		},

		statusValue: function(sValue) {
			if (!sValue) {
				return "";
			}
			var resourceBundle = this.getView().getModel("i18n").getResourceBundle();
			switch (sValue) {
				case "0":
					return resourceBundle.getText("reqStatusSubmitted");
				case "1":
					return resourceBundle.getText("reqStatusApproving");
				case "2":
					return resourceBundle.getText("reqStatusCancelled");
				case "3":
					return resourceBundle.getText("reqStatusReturned");
				case "4":
					return resourceBundle.getText("reqStatusRejected");
				case "S":
					return resourceBundle.getText("reqStatusProcessedS");
				case "E":
					return resourceBundle.getText("reqStatusProcessedE");
			}
		},

		noLeadingZero: function(sValue) {
			if (!sValue) {
				return "";
			} else {
				return sValue.replace(/\b(0+)/gi, "");
			}
		},

		formatSizeAttribute: function(sValue) {
			if (!sValue) {
				return "";
			} else {
				return FileSizeFormat.getInstance({
					binaryFilesize: false,
					maxFractionDigits: 1,
					maxIntegerDigits: 3
				}).format(sValue);
			}

		},

		dateTimeZHValue: function(sValue) {
			if (!sValue) {
				return "";
			} else {
				sValue = sValue.replace(/^\s+|\s+$/g, ""); //js去掉两头空格
				if (!sValue) {
					return "";
				}
				if (sValue === "00000000000000") {
					return "";
				}

				sValue = sValue.replace(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/, "$1/$2/$3 $4:$5:$6");
				return sValue;
			}
		}
	};
});